package com.ewhale.feitengguest.presenter.shop.task

import com.ewhale.feitengguest.api.ApiHelper
import com.ewhale.feitengguest.dto.WaitHandleDto
import com.ewhale.feitengguest.view.shop.deal.SDealView
import com.ewhale.feitengguest.view.shop.task.SubmitListView
import com.simga.library.base.IPresenter
import com.simga.library.http.APIException

class SubmitListPresenter : IPresenter() {

    fun loadSubmitList(missionId: Long, status: Int, pageNumber: Int) {
        request(1, ApiHelper.TASK_API.getSubmitListByMissionId(missionId, status, pageNumber, 10), null)
    }

    override fun <T : Any?> onNext(postCode: Int, result: T, data: Any?) {
        super.onNext(postCode, result, data)
        when (postCode) {
            1 -> (mView as SubmitListView).showDealList(result as List<WaitHandleDto>)
        }
    }

    override fun otherException(postCode: Int, data: Any?, e: APIException?) {
        super.otherException(postCode, data, e)
        mView.showErrorMessage(postCode, e!!.code, e.displayMessage)
    }

}
